/*
 * @Date: 2023-06-06 14:50:44
 * @LastEditors: Chuying
 * @LastEditTime: 2023-06-07 10:23:42
 * @Description: 
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ceo_app/page/home/index.dart';
import 'package:ceo_app/page/square/index.dart';
import 'package:ceo_app/page/personal/index.dart';

class Index extends StatefulWidget {
  const Index({Key? key}) : super(key: key);

  @override
  _IndexState createState() => _IndexState();
}

class _IndexState extends State<Index> {
  static int _currentIndex = 0;
  final List<Widget> _pages = const [
    Home(),
    Square(),
    Personal(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(backgroundColor: Colors.white, toolbarHeight: 0),
      body: Stack(
        children: [
          _pages[_currentIndex],
          Positioned(
            bottom: 20,
            right: 14,
            child: _currentIndex == 2
                ? const Text('')
                : GestureDetector(
                    onTap: () {
                      debugPrint('你好');
                      Navigator.pushNamed(context, '/publish');
                    },
                    child: Container(
                      alignment: Alignment.center,
                      width: 100,
                      height: 40,
                      decoration: const BoxDecoration(
                          color: Color(0xff222222),
                          borderRadius: BorderRadius.all(Radius.circular(21))),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Image.asset(
                            'assets/images/orangeAdd.png',
                            height: 12.w,
                            width: 12.w,
                          ),
                          const Text(
                            '发布内容',
                            style: TextStyle(
                                fontSize: 14,
                                color: Colors.white,
                                fontWeight: FontWeight.w500),
                          )
                        ],
                      ),
                    )),
          )
        ],
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        unselectedItemColor: Colors.black,
        selectedItemColor: Colors.black,
        onTap: (int index) {
          setState(() {
            _currentIndex = index;
          });
        },
        items: const [
          BottomNavigationBarItem(
            icon: Icon(Icons.home_filled),
            activeIcon: Icon(Icons.home_filled),
            label: '首页',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.image),
            activeIcon: Icon(Icons.image),
            label: '福利',
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.man),
            activeIcon: Icon(Icons.man),
            label: '我的',
          ),
        ],
      ),
    );
  }
}
